package org.wkg.lesson01;

public class DemoAll {
    public static void main(String[] args) {
        /*MyThread3 myThread3 = new MyThread3();
        myThread3.start();
        while (true){
            try {
                Thread.sleep(1000);
                System.out.println("My Main run.....");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }*/

        /*MyRunnable04 myRunnable04 = new MyRunnable04();
        MyRunnable05 myRunnable05 = new MyRunnable05();

        Thread thread1 = new Thread(myRunnable04);
        Thread thread2 = new Thread(myRunnable04);
        Thread thread3 = new Thread(myRunnable05);
        thread1.start();
        thread2.start();
        thread3.start();*/

        /*Thread thread = new Thread() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                        System.out.println("Thread匿名内部类.....");
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };*/
        //thread.start();

        /*Thread thread=new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                        System.out.println("Runnable匿名内部类.....");
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });
        thread.start();*/

        Thread thread=new Thread(()->{
            while (true){
                try {
                    Thread.sleep(1000);
                    System.out.println("使用Lambda表达式运行Thread.....");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        thread.start();
        while (true) {
            try {
                Thread.sleep(1000);
                System.out.println("My Main run.....");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }


    }
}


class MyThread3 extends Thread {
    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
                System.out.println("My Thread run.....");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

class MyRunnable04 implements Runnable {
    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
                System.out.println("生产皮鞋，金币+20.....");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

class MyRunnable05 implements Runnable {
    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
                System.out.println("生产皮包，金币+10.....");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}